package com.zixun.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.zixun.Models.DiaryInfo;
import com.zixun.R;

/**
 * 作者：郭郭
 * 消息窗口
 */

public class NewsActivity extends Activity {
    private EditText edt_news;
    private Button btn_save;
    private Button btn_cancel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);

        initView();
    }

    private void initView() {
        edt_news = (EditText) findViewById(R.id.edt_news);
        btn_save = (Button) findViewById(R.id.btn_save);
        btn_cancel = (Button) findViewById(R.id.btn_cancel);

        btn_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(edt_news.getText().toString())) {
                    Intent intent = new Intent();
                    intent.putExtra("description", edt_news.getText().toString());
                    setResult(1, intent);
                    finish();
                } else {
                    Toast.makeText(NewsActivity.this, "心情不能为空！", Toast.LENGTH_SHORT).show();
                }
            }
        });

        btn_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setResult(0);
                finish();
            }
        });
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        setResult(0);
        finish();
    }

}
